import request from '../utils/request';

/**
 * 获取订单列表
 * @param {Object} params 查询参数，包含teacherId
 * @returns {Promise} 订单列表
 */
export async function getOrders(params) {
  return request.get('/api/admin/orders', { params });
}

/**
 * 获取订单详情
 * @param {number|string} id 订单ID
 * @param {Object} params 额外参数，包含teacherId
 * @returns {Promise} 订单详情
 */
export async function getOrderDetail(id, params = {}) {
  return request.get(`/api/admin/orders/${id}`, { params });
}

/**
 * 更新订单支付状态
 * @param {number|string} id 订单ID
 * @param {Object} data 支付状态数据，包含teacherId
 * @returns {Promise} 更新结果
 */
export async function updateOrderPayment(id, data) {
  return request.put(`/api/admin/orders/${id}/payment`, data);
}

/**
 * 处理订单退款
 * @param {number|string} id 订单ID
 * @param {Object} data 退款数据，包含teacherId
 * @returns {Promise} 退款结果
 */
export async function refundOrder(id, data) {
  return request.post(`/api/admin/orders/${id}/refund`, data);
}

/**
 * 获取订单统计数据
 * @param {Object} params 查询参数，包含teacherId
 * @returns {Promise} 统计数据
 */
export async function getOrderStatistics(params) {
  return request.get('/api/admin/orders/statistics/summary', { params });
}

/**
 * 获取销售趋势数据
 * @param {Object} params 查询参数，包含teacherId
 * @returns {Promise} 趋势数据
 */
export async function getOrderTrend(params) {
  return request.get('/api/admin/orders/statistics/trend', { params });
}

/**
 * 获取热门课程销售数据
 * @param {Object} params 查询参数，包含teacherId
 * @returns {Promise} 热门课程数据
 */
export async function getHotCourses(params) {
  return request.get('/api/admin/orders/statistics/hot-courses', { params });
}

export default {
  getOrders,
  getOrderDetail,
  updateOrderPayment,
  refundOrder,
  getOrderStatistics,
  getOrderTrend,
  getHotCourses
}; 